Skip to content

feat(stow-guard): the token-line ask asks for a quick save, the daily ask keeps the full pass - #297

Merged
arjmad merged 5 commits into
mainfrom
fm/stow-guard-quick-save-1122
Nov 22, 2026
Merged

arjmad merged 5 commits into
mainfrom
fm/stow-guard-quick-save-1122

Conversation

@arjmad

@arjmad arjmad commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

At its token line, the stow guard now asks for a short save (/stow quick), not a full /stow.
The daily age ask still asks for the full pass.
Arjun approved this in the helm on 2026-11-22.
Evidence from that day: the guard asks at tokens=240000, compaction is near 300K, and a full pass did not fit in the gap. Compaction hit in the middle of the pass, and the helm had to re-read its 69KB startup digest to finish.

 Stop hook: fm-stow-guard.sh
   context ask (tokens >= line, once per crossing)
-    "Run the /stow skill now (full pass)"
+    "Run the stow skill now with the argument quick (/stow quick) for a quick save"
   age ask (newest full /stow older than hours=, default 24)
-    "Run the /stow skill now (full pass)"
+    "Run the /stow skill now (full pass, no argument)"
   transcript read for last_stow
     Skill call, skill == "stow"
+    and the first word of input.args is not "quick" (any case)
 stow skill (.agents/skills/stow/SKILL.md; .claude/skills is a symlink to it)
+  Quick save (first argument word "quick"):
+    knowledge sweep + open-record persistence only
+      (file findings, correct stale row notes, captain answers via fm-captain-hold.sh answer)
+    new memory entry only when fm-startup-memory-budget.sh report shows room,
+      else leave it on its task row for the next full pass
+    no startup-memory pass, no cascade, no restart question
+    short receipt that never says reset-safe
   Full pass (no argument, or any other argument): unchanged

The clock rule (brief item 3): a quick save does not move last_stow in state/.stow-guard.json, so the 24-hour full pass still comes due after quick saves.
The guard tells the two apart by the Skill call's input.args, the field Claude Code writes when a skill gets args. A live transcript shows {"skill":"tstack-sol-loop","args":"..."}, and the skill body receives it as ARGUMENTS: ....
A mis-invoked save (args like quickly) counts as a full pass. That can delay the age ask, but it never makes the clock look older than it is.

These are unchanged: the once-per-crossing state, asked, offer handling, restart=1, and the rule that a guard ask never offers a restart.
A /stow quick the captain types still records an offer, as before. The quick save never says reset-safe, so it never asks him to start fresh.

The age ask now also waits while the context reading is at or above the token line. The merge-gate review found this case: quick saves no longer reset the clock, so without the wait, the daily ask could ask for a full pass in the same gap before compaction. When both asks are due at one stop, the context ask wins. The age ask then waits at least an hour, and until the context drops below the line. A test pins this.

The decision record is docs/fork-decisions/2026-11-22-stow-guard-quick-save.md, not a line in docs/fork-decisions.md. The repo keeps one record per file, and bin/fm-fork-decisions.sh check rejects records added to the index page.

Evidence

  • Before: the guard's context ask with restart=1 said Run the /stow skill now (full pass). Every stow Skill call moved last_stow.
    The updated suite, run against the main guard, fails as expected:
    not ok - the guard's ask with restart=1 did not block with 'with the argument quick (/stow quick) for a quick save, ...':
      {"decision":"block","reason":"fm-stow-guard: context is 1200 tokens, near auto-compaction. Run the /stow skill now (full pass), then continue the turn you were in."}
    
  • After: tests/fm-stow-guard.test.sh passes 18 of 18. The three new tests cover:
    • test_each_ask_names_its_pass: the context ask names /stow quick and not the full pass; the age ask names the full pass and not quick.
    • test_quick_save_does_not_move_the_full_pass_clock:
      • a quick save newer than a full pass leaves last_stow on the full pass;
      • a tail with only quick saves ( Quick, quick\t..., QUICK) still gets the age ask a day later;
      • quickly please counts as a full pass;
      • a quick-only first stop starts the clock at now.
    • test_both_asks_due_asks_quick_then_full_below_the_line: the age ask stays silent an hour later while the context is over the line, and asks for the full pass once it drops below.
  • bin/fm-test-run.sh --near: total=3 failed=0 skipped_gate=1 (the opt-in live prompt guard).
  • bin/fm-lint.sh bin/fm-stow-guard.sh tests/fm-stow-guard.test.sh, bin/fm-fork-decisions.sh check, bin/fm-fork-decisions.sh pr-check --base origin/main (upstream-owned=4 records=1) and bin/fm-doc-audience-check.sh: all ok.

Merge Danger

Door: two-way

A revert restores the old message and clock rule. The state file format is unchanged, so no stored state needs migration.

Blast Radius: stow-guard

It reaches only homes with config/stow-guard, and only Claude primaries. After an upgrade, the first age ask may come earlier than a home expects, because quick saves no longer reset the clock.

Reviewed with sol-loop: 3 rounds with gpt-6.2-sol. Sol verdict: approved

… ask keeps the full pass

The context ask now asks for /stow quick, which runs only the knowledge
sweep and open-record persistence. The age ask still asks for the full
pass, and a stow Skill call whose first argument word is quick does not
move last_stow, so the full pass still comes due once a day.
Comment thread bin/fm-stow-guard.sh Outdated
fired=$(jq -c --arg sid "$sid" '.[$sid] = true' <<<"$fired") || exit 0
elif [ "$saves_readable" -eq 1 ] && [ -z "$last_stow" ]; then
last_stow=$now
elif [ "$saves_readable" -eq 1 ] && [ $((now - last_stow)) -ge "$max_age" ] && [ $((now - asked)) -ge 3600 ]; then

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The age ask can still ask for a full pass while the session is above the token line. This PR set out to stop exactly that, and the case is wider than the 'both due at one stop' limit the PR accepts. Example: the context ask fires at hour 23 since the last full pass, and the quick save no longer moves last_stow. At hour 24 the age branch fires (the context branch is skipped because fired[sid] is already true) and asks for a full pass, even though tokens are still at or above the threshold. Fix: skip or defer the age ask while tokens >= threshold (or while fired[sid] is true), so it waits until the context has dropped below the line.

Failure scenario: tokens=240000, last full stow 23h ago. Stop A has 250K tokens, so the context ask asks for /stow quick, which runs and leaves last_stow unchanged. The helm keeps working for 61 more minutes at 260-290K. Stop B finds now-last_stow >= 24h and now-asked >= 3600, so it blocks with 'Run the /stow skill now (full pass, no argument)'. The full pass then starts about 10-50K tokens before compaction, and compaction hits mid-pass. That is the failure cited in the decision record.

@arjmad

arjmad commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

bin/fm-stow-guard.sh:153: A typed /stow quick still records a restart offer through the prompt hook. The quick save can never use it, because the skill says it never says reset-safe. The offer stays valid for FM_HELM_REFRESH_OFFER_TTL (7200s). Within those two hours, any later full pass that ends reset-safe finds an offer whose sid matches state/.lock-session. SKILL.md's restart rule (line 305) keys only on that record, so the agent may ask the captain to start fresh. bin/fm-helm-refresh.sh request then accepts it, even though the full pass was guard-started or agent-started. Fix: in prompt mode, do not record an offer when the first argument word is quick (match the same any-case first-word rule the Stop path uses).

Failure scenario: restart=1. The captain types /stow quick, which writes offer {sid, at=now}. Thirty minutes later the age ask (or an agent) runs a full /stow and its receipt is reset-safe. The offer sid matches the lock session and is younger than 7200s, so the skill's line-305 condition holds. The agent asks 'Start fresh now', and fm-helm-refresh.sh request passes its offer check for a stow the captain never typed as a full pass.

@arjmad

arjmad commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

Re the /stow quick offer finding (nit): declined in this PR.
The brief for this change keeps the offer handling unchanged, and the prompt hook's own test (test_typed_stow_records_the_offer, the typed-stow-args case) pins /stow quick recording an offer.
The case is also already accepted in docs/fork-decisions/2026-11-22-typed-stow-restarts-helm.md: "A typed offer also stays valid for its TTL across a later guard-asked /stow; the skill's question, asked only after a typed /stow, is what keeps that /stow from restarting."
The skill's restart rule opens with "When the captain typed /stow himself", so a later guard-started or agent-started full pass asks nothing.
Narrowing the offer to a typed full /stow is a fair follow-up for the offer's owner.

The age-ask finding (important) is fixed in 37007e0: the age ask now waits while the context is at or above the token line, and test_both_asks_due_asks_quick_then_full_below_the_line pins it.

@arjmad

arjmad commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

Code review: Claude Code /code-review (medium) ran on this diff; each finding is posted inline and was fixed or answered in its thread.
Sol: 3 rounds, gpt-6.2-sol, approved

@arjmad
arjmad merged commit a2fee0d into main Nov 22, 2026
33 checks passed
@arjmad
arjmad deleted the fm/stow-guard-quick-save-1122 branch November 22, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant